package com.project;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * Hello world!
 *
 */
@SpringBootApplication
@EnableFeignClients
public class GateWayStart
{
    public static void main( String[] args )
    {

        SpringApplication.run(GateWayStart.class,args);
    }

    @Bean("ipKeyKeyResolver")
    public KeyResolver ipKeyKeyResolver(){
        return new KeyResolver() {
            @Override
            public Mono<String> resolve(ServerWebExchange exchange) {

                return Mono.just(exchange.getRequest().getRemoteAddress().getHostName());
            }
        } ;
    }
}
